package com.thoughtworks.biblioteca.controller;

import com.thoughtworks.biblioteca.dao.BookDao;
import com.thoughtworks.biblioteca.model.Book;

public class BookController {
    private BookDao bookDao;

    public String listBookCatalog() {
        StringBuffer bf = new StringBuffer("");
        for (Book book : bookDao.getAllBooks()) {
            bf.append(book.getId());
            bf.append(". ");
            bf.append(book.getName());
            bf.append(" by ");
            bf.append(book.getAuthor());
            bf.append("\n");
        }
        return bf.toString();
    }


    public String checkoutResult(int bookID) {
        if (bookDao.isExsitingBook(bookID))
            return "\n Thank You! Enjoy the book.";
        return "\n Sorry we don't have that book yet.";
    }

    public BookDao getBookDao() {
        return bookDao;
    }

    public void setBookDao(BookDao bookDao) {
        this.bookDao = bookDao;
    }
}
